# from itsdangerous import TimedJSONWebSignatureSerializer as TJWSSerializer
# from itsdangerous import BadData
#
#
# # itsdangerous: 进行数据的签名加密和解密
# # 安装: pip install itsdangerous
#
# if __name__ == "__main__":
#         req_data = 'eyJleHAiOjE1NDg1ODA1NDYsImFsZyI6IkhTMjU2IiwiaWF0IjoxNTQ4NTc2OTQ2fQ.eyJvcGVuaWQiOiJLREtLU0RKSkRKVVExMjgzaUtETExEIn0.iugxCyCeJPr398tEw0ts1i8CjW-Cw82e_wAOlbfPdvE'
#
#         # 解密
#         serializer = TJWSSerializer(secret_key='123456abc')
#         try:
#             res_dict = serializer.loads(req_data)
#         except BadData:
#             print('解密失败')
#         else:
#             print(res_dict)
#
# if __name__ == "__main__":
#     my_dict = {
#     'openid': 'KDKKSDJJDJUQ1283iKDLLD'
#     }
#
#     # 签名加密
#     # TJWSSerializer(secret_key='密钥', expires_in='解密有效时间: s')
#     serializer = TJWSSerializer(secret_key='123456abc', expires_in=3600)
#     res = serializer.dumps(my_dict) # bytes
#
#     # bytes->str
#     res = res.decode()
#
#     print(res)